#Copyright Ken Faulkner 2007.
import traceback

import  wx
from configobj import ConfigObj
from Common.logRoutine import *
import confignotebook
import os
import os.path

class ConfigDialog(wx.Dialog):
  def __init__(
    self, parent, ID, title, size, pos=wx.DefaultPosition, 
    style=wx.DEFAULT_DIALOG_STYLE
    ):

    # system config.
    self.home_dir = os.path.join( os.getenv("HOME"), ".bbc")

    self.config = ConfigObj( os.path.join( self.home_dir, "bbc.cfg") )
    self.searchConfig = ConfigObj( os.path.join( self.home_dir, "user.cfg") )
    self.log = getLogger()
    
    pre = wx.PreDialog()
    pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
    pre.Create(parent, ID, title, pos, size, style)

    self.PostCreate(pre)

    sizer = wx.BoxSizer(wx.VERTICAL)

    self.nb = confignotebook.ConfigNotebook( self, -1 )
    sizer.Add( self.nb )
    
    label = wx.StaticText(self, -1, "Configuration")
    label.SetHelpText("This is the help text for the label")
    sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

    line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
    sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

    btnsizer = wx.StdDialogButtonSizer()
    
    btn = wx.Button(self, wx.ID_OK)
    btn.SetDefault()
    btnsizer.AddButton(btn)

    btn = wx.Button(self, wx.ID_CANCEL)
    btnsizer.AddButton(btn)
    btnsizer.Realize()

    sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
    
    self.SetSizer(sizer)
    sizer.Fit(self)
